package com.hz.ruoyilgorder.config;

import com.hz.rouyigonggong.domain.LgDriverLogistics;
import com.hz.rouyigonggong.domain.dto.LgDriverLogisticsDTO;
import org.springframework.beans.BeanUtils;

public class LgDriverLogisticsConverter {

    /**
     * 将 LgDriverLogistics 转换为 LgDriverLogisticsDTO
     * @param logistics 司机物流实体
     * @return 司机物流 DTO
     */
    public static LgDriverLogisticsDTO toDTO(LgDriverLogistics logistics) {
        if (logistics == null) {
            return null;
        }
        LgDriverLogisticsDTO dto = new LgDriverLogisticsDTO();
        BeanUtils.copyProperties(logistics, dto);
        return dto;
    }

    /**
     * 将 LgDriverLogisticsDTO 转换回 LgDriverLogistics
     * @param dto 司机物流 DTO
     * @return 司机物流实体
     */
    public static LgDriverLogistics toEntity(LgDriverLogisticsDTO dto) {
        if (dto == null) {
            return null;
        }
        LgDriverLogistics logistics = new LgDriverLogistics();
        logistics.setId(dto.getId());
        logistics.setLogisticsOrderNumber(dto.getLogisticsOrderNumber());
        logistics.setTemperatureRange1(dto.getTemperatureRange1());
        logistics.setTemperatureRange2(dto.getTemperatureRange2());
        logistics.setDriverId(dto.getDriverId());
        logistics.setVehicleId(dto.getVehicleId());
        logistics.setVerifiedWeight(dto.getVerifiedWeight());
        logistics.setVolume(dto.getVolume());
        logistics.setInspectionText(dto.getInspectionText());
        logistics.setSellerSignature(dto.getSellerSignature());
        logistics.setDriverSignature(dto.getDriverSignature());
        logistics.setCreateBy(dto.getCreateBy());
        logistics.setCreateTime(dto.getCreateTime());
        logistics.setUpdateBy(dto.getUpdateBy());
        logistics.setUpdateTime(dto.getUpdateTime());
        logistics.setStatus(dto.getStatus());
        logistics.setImage(dto.getImage());

        return logistics;
    }
}
